@extends('admin.layouts.index')
@section('content')
	<div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; <a href="#">商品管理</a> &raquo; 添加商品
    </div>
	<div class="search_wrap">
        <form action="{{url('/admin/user')}}" method="get">
            <table class="search_tab">
                <tr>
                    <th width="120">选择分类:</th>
                    <td>
                        <select name="count">
                            <option value="3" @if(!empty($count) && $count == 3) selected @endif>3</option>
                            <option value="10" @if(!empty($count) && $count == 10) selected @endif>10</option>
                            <option value="25" @if(!empty($count) && $count == 25) selected @endif>25</option>
                            <option value="50" @if(!empty($count) && $count == 50) selected @endif>50</option>
                         </select>条
                    </td>
                    <th width="70">关键字:</th>
                    <td><input type="text" name="keywords" placeholder="关键字" value="{{$keywords}}"></td>
                    <td><input type="submit" value="查询"></td>
                </tr>
            </table>
        </form>
    </div>
    <!--结果页快捷搜索框 结束-->

    <!--搜索结果页面 列表 开始-->
    <form action="#" method="post">
        <div class="result_wrap">
            <!--快捷导航 开始-->
            <div class="result_content">
                <div class="short_wrap">
                    <a href="#"><i class="fa fa-plus"></i>新增文章</a>
                    <a href="#"><i class="fa fa-recycle"></i>批量删除</a>
                    <a href="#"><i class="fa fa-refresh"></i>更新排序</a>
                </div>
            </div>
            <!--快捷导航 结束-->
        </div>

        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
                    <tr>
                        <th class="tc">ID</th>
                        <th>用户</th>
                        <th>密码</th>
                        <th>操作</th>
                    </tr>
                    @foreach($data as $k=>$v)
                    <tr>
                        <td class="tc">{{$v->id}}</td>
                        <td>{{$v->username}}</td>
                        <td>{{$v->password}}</td>
                        <td>
                            <a href="http://www.bbs.com/admin/user/auth/{{$v->id}}">权限</a>
                            <a href="http://www.bbs.com/admin/user/{{$v->id}}/edit">修改</a>
                            <a href="javascript:;" onclick="delUser({{$v->id}})">删除</a>
                        </td>
                    </tr>
                    @endforeach
                </table>


<div class="page_nav">
<div>
{!! $data->appends($res)->render() !!}

</div>
</div>



                <div class="page_list">
                </div>
            </div>
        </div>
    </form>
    <script type="text/javascript">
        function delUser(userid){

            layer.confirm('确认删除吗？', {
                btn: ['确定','取消'] //按钮
            }, function(){
                //向服务器发送删除请求
//                $.ajax(请求的路径，携带的参数，返回的结果)
//                url===>admin/user/21
                $.post("{{url('admin/user/')}}/ "+userid,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                       if( data.status == 0){
//                            将json格式的字符串变成json对象
//                           var data = JSON.parse(data);
                           layer.msg(data.msg, {icon: 6});
                           location.href = location.href;
                       }else{
                           layer.msg(data.msg, {icon: 5});
                           location.href = location.href;
                       }
                });
                //
            }, function(){

            });
        }
    </script>

@endsection